import { httpUrl } from 'api/config';
import { ajaxPostNoToken } from 'api/axios';
import { changeDataType } from 'common/js/util';

export function getUpdateJournalData() {
	let url = `${httpUrl}/index/listEditLog`;
	
	let data = {};

	return ajaxPostNoToken(url, data)
		.then(res => {
			return Promise.resolve(res)
		})
		.catch(res => {
			return Promise.reject(res)
		})
}

export function getStrustDetailed() {
	let url = `${httpUrl}/index/listApi`;
	
	let data = {};

	return ajaxPostNoToken(url, data)
		.then(res => {
			return Promise.resolve(res)
		})
		.catch(res => {
			return Promise.reject(res)
		})
}

export function getHandlerDetailed() {
	let url = `${httpUrl}/index/listHandlerApi`;
	
	let data = {};

	return ajaxPostNoToken(url, data)
		.then(res => {
			return Promise.resolve(res)
		})
		.catch(res => {
			return Promise.reject(res)
		})
}

export function getStrustJournal(search = {}, page = 1) {
	let url = `${httpUrl}/index/strustlog`;
	
	let data = {
		page: page,
		rows: 10,
		...search
	};

	return ajaxPostNoToken(url, changeDataType(data))
		.then(res => {
			return Promise.resolve(res)
		})
		.catch(res => {
			return Promise.reject(res)
		})
}

export function getHandlerJournal(search = {}, page = 1) {
	let url = `${httpUrl}/index/handlerlog`;
	
	let data = {
		page: page,
		rows: 10,
		...search
	};

	return ajaxPostNoToken(url, changeDataType(data))
		.then(res => {
			return Promise.resolve(res)
		})
		.catch(res => {
			return Promise.reject(res)
		})
}

export function getFunctionJournalList(search = {}, page = 1) {
	let url = `${httpUrl}/index/tasklog`;
	
	let data = {
		page: page,
		rows: 10,
		...search
	};

	return ajaxPostNoToken(url, changeDataType(data))
		.then(res => {
			return Promise.resolve(res)
		})
		.catch(res => {
			return Promise.reject(res)
		})
}

export function getFunctionJournalStatus() {
	let url = `${httpUrl}/index/taskInfo`;
	
	let data = {};

	return ajaxPostNoToken(url, data)
		.then(res => {
			return Promise.resolve(res)
		})
		.catch(res => {
			return Promise.reject(res)
		})
}

export function getSystemDocument() {
	let url = `${httpUrl}/index/filelist`;
	
	let data = {};

	return ajaxPostNoToken(url, data)
		.then(res => {
			return Promise.resolve(res)
		})
		.catch(res => {
			return Promise.reject(res)
		})
}
